package com.SunSoft.PhoneRemoteControl;

import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;
import java.lang.reflect.Field;
import java.util.ArrayList;

final class cf
  implements DialogInterface.OnClickListener
{
  public final void onClick(DialogInterface paramDialogInterface, int paramInt)
  {
    Object localObject;
    String str1 = "";
    try
    {
      localObject = paramDialogInterface.getClass().getSuperclass().getDeclaredField("mShowing");
      ((Field)localObject).setAccessible(true);
      ((Field)localObject).set(paramDialogInterface, Boolean.valueOf(false));
      paramInt = 0;
      if (paramInt < this.a.bR)
        break label172;
      if (this.a.bR != 15)
        break label404;
      paramInt = this.a.bL[this.a.bI][0];
      localObject = this.a.bO[paramInt];
      if ((localObject != null) && (((String)localObject).length() >= 11))
        break label425;
      this.b.setText(this.a.getString(2131099918));
      Toast.makeText(this.a, this.a.getString(2131099918), 0).show();
      label772: label903: label404: label425: label172: return;
    }
    catch (SecurityException paramDialogInterface)
    {
      paramDialogInterface.printStackTrace();
    }
    catch (NoSuchFieldException paramDialogInterface)
    {
      paramDialogInterface.printStackTrace();
    }
    catch (IllegalArgumentException paramDialogInterface)
    {
      paramDialogInterface.printStackTrace();
    }
    catch (IllegalAccessException paramDialogInterface)
    {
      String str2;
      while (true)
      {
        while (true)
          paramDialogInterface.printStackTrace();
        if (this.a.bR == 15)
        {
          this.a.bT = this.a.bU[paramInt].getSelectedItemPosition();
          this.a.bS = Integer.valueOf((String)this.a.bK.get(this.a.bT)).intValue();
          this.a.bL[this.a.bI][paramInt] = this.a.bS;
        }
        while (true)
        {
          while (true)
          {
            MainControl.a("Test", String.valueOf(paramInt) + ":" + String.valueOf(this.a.bT) + "," + String.valueOf(this.a.bS));
            paramInt += 1;
          }
          this.a.bT = this.a.bV[paramInt].getSelectedItemPosition();
          this.a.bS = Integer.valueOf((String)this.a.bK.get(this.a.bT)).intValue();
          this.a.bM[this.a.bI][paramInt] = this.a.bS;
        }
        paramInt = this.a.bM[this.a.bI][0];
      }
      int i = ((String)localObject).length() / 2;
      paramInt = i + 5 + (i - 11) * (this.a.bR - 1);
      if (paramInt > 255)
      {
        paramInt -= 255;
        paramDialogInterface = "FD" + MainControl.a(paramInt) + MainControl.a(1L) + "0000" + ((String)localObject);
        MainControl.a("Test", "power_code:" + ((String)localObject));
        MainControl.a("Test", "key_code_len:" + String.valueOf(i));
        MainControl.a("Test", "download_len:" + String.valueOf(paramInt));
        str2 = ((String)localObject).substring(22);
        paramInt = 0;
      }
      while (true)
      {
        while (paramInt >= str2.length())
        {
          paramInt = 1;
          if (paramInt < this.a.bR)
            break label772;
          MainControl.a("Test", "download_code len:" + String.valueOf(paramDialogInterface.length() / 2));
          MainControl.a("Test", "download_code:" + paramDialogInterface);
          MainControl.a(this.a, paramDialogInterface, 0);
          this.b.setText(this.a.getString(2131099920));
          Toast.makeText(this.a, this.a.getString(2131099920), 0).show();
          return;
          paramDialogInterface = "FE" + MainControl.a(paramInt) + MainControl.a(1L) + "0000" + ((String)localObject);
        }
        str1 = str1 + "0";
        paramInt += 1;
      }
      if (this.a.bR == 15)
      {
        i = this.a.bL[this.a.bI][paramInt];
        str2 = this.a.bO[i];
        if ((str2 != null) && (str2.length() == ((String)localObject).length()))
          break label903;
        paramDialogInterface = paramDialogInterface + str1;
        MainControl.a("Test", "len errror:" + String.valueOf(i));
      }
      while (true)
      {
        while (true)
        {
          while (true)
            paramInt += 1;
          i = this.a.bM[this.a.bI][paramInt];
        }
        str2 = str2.substring(22);
        paramDialogInterface = paramDialogInterface + str2;
      }
    }
  }
}